package com.xishu.entity.foodpanda;

import com.xishu.annotation.dao.DefaultValue;
import com.xishu.annotation.dao.FieldMapping;
import com.xishu.annotation.dao.NotModify;
import com.xishu.annotation.dao.Search;
import com.xishu.annotation.lang.Lang;
import com.xishu.annotation.oplog.OplogAnnotation;
import com.xishu.annotation.sort.ShowOrder;
import com.xishu.entity.AbstractEntity;
import com.xishu.entity.shop.ItemDetail;
import com.xishu.entity.shop.PriceConfig;
import com.xishu.entity.shop.SetMenuOneItem;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.*;
import java.util.List;

@Entity(name = "product")
@Table(indexes = {@Index(columnList = "shopId"), @Index(columnList = "belongToItemId")})
@Data
public class Product extends AbstractEntity {
    private static final long serialVersionUID = -7525437536126956738L;

    @ApiModelProperty(value = "归属的餐厅公司")
    private Long companyId;

    @ApiModelProperty(value = "分店的ID")
    private Long shopId;

    @ApiModelProperty(value = "归属于哪一个菜")
    @NotModify
    private Long belongToItemId;

    @ApiModelProperty(name = "菜品的名称")
    @Search(like = true)
    @OplogAnnotation(fieldName = "菜品的名称")
    @Lang(key = "name")
    private String name;

    @ApiModelProperty(name = "菜品的名称")
    @Search(like = true)
    @OplogAnnotation(fieldName = "菜品的名称")
    @Lang(key = "name")
    private String name_zh;

    @ApiModelProperty(name = "菜品的名称")
    @Search(like = true)
    @OplogAnnotation(fieldName = "菜品的名称")
    @Lang(key = "name")
    private String name_en;

    @ApiModelProperty(value = "图片ID")
    @OplogAnnotation(fieldName = "图片ID")
    private String imgId;

    @ApiModelProperty(value = "菜品描述")
    @Lang(key = "description", lang = "")
    private String description;

    @ApiModelProperty(value = "菜品描述中文")
    @Lang(key = "description", lang = "zh")
    private String description_zh;

    @ApiModelProperty(value = "菜品描述英文")
    @Lang(key = "description", lang = "en")
    private String description_en;

    @ApiModelProperty(value = "是否是套餐")
    @OplogAnnotation(fieldName = "是否是套餐")
    private Boolean setMenu;

    @ApiModelProperty(value = "新版本的套餐里面的每一项")
    @Transient
    @FieldMapping(desField = "setMenuOneItemJson", serialize = true)
    @DefaultValue(defaultValue = "")
    private List<SetMenuOneItem> setMenuOneItemList;

    @ApiModelProperty(value = "新版本的套餐里面的每一项")
    @FieldMapping(desField = "setMenuOneItemList", serialize = false, genericType = "com.xishu.entity.shop.SetMenuOneItem")
    @Lob
    @Column(columnDefinition = "MEDIUMTEXT")
    private String setMenuOneItemJson;

    @ApiModelProperty(value = "是否上架")
    @OplogAnnotation(fieldName = "是否上架")
    private Boolean online;

    @ApiModelProperty(value = "归属于哪一个品类")
    private Long categoryId;

    @ApiModelProperty(value = "品类名字")
    private String categoryName;

    @ApiModelProperty(value = "品类名字-中文")
    private String categoryName_zh;

    @ApiModelProperty(value = "品类名字-英文")
    private String categoryName_en;

    @ApiModelProperty(value = "排序")
    @ShowOrder
    private Integer showOrder;

    @Transient
    @FieldMapping(desField = "itemDetailJson", serialize = true)
    @ApiModelProperty(value = "菜品细节，也是菜品规格")
    @OplogAnnotation(fieldName = "菜品细节")
    private List<ItemDetail> itemDetailList;

    @FieldMapping(desField = "itemDetailList", serialize = false, genericType = "com.xishu.entity.shop.ItemDetail")
    @ApiModelProperty(value = "菜品细节，也是菜品规格")
    @Lob
    @Column(columnDefinition = "MEDIUMTEXT")
    @OplogAnnotation(fieldName = "菜品细节")
    private String itemDetailJson;

    @FieldMapping(desField = "priceConfigJson", serialize = true)
    @Transient
    @OplogAnnotation(fieldName = "场景价格")
    private List<PriceConfig> priceConfigList;

    @FieldMapping(desField = "priceConfigList", serialize = false, genericType = "com.xishu.entity.shop.PriceConfig")
    @Column(length = 1024)
    @OplogAnnotation(fieldName = "场景价格,对应的menu里面的价格，依然用sceneId来表示")
    private String priceConfigJson;

    @ApiModelProperty(value = "发送厨房别名")
    @Lang(key = "printAlias")
    private String printAlias;

    @ApiModelProperty(value = "发送厨房别名")
    @Lang(key = "printAlias")
    private String printAlias_zh;

    @ApiModelProperty(value = "发送厨房别名")
    @Lang(key = "printAlias")
    private String printAlias_en;
}
